script_enemy_main{

let shot1=0;
let bullet1=[];
let timer1=[];

let character="Hotaru";
let cutin=character;
let dispelled=0;
let spellcards=5;
if(GetCommonData("Difficulty")>=3){ spellcards=6; }
let damagerate=10;
let outfit=6;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotb6=("\script\SoundEffects\shotb6.wav");
let SEfireworks1=("\script\SoundEffects\fireworks1.wav");

let GRboss=("\script\Images\CharacterSprites\Hotaru.png");

#include_function "script/Functions/HealthBarLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsHotaru1.txt");

	LoadSE("\script\SoundEffects\shotb6.wav");
	LoadSE("\script\SoundEffects\fireworks1.wav");

	LoadGraphic("\script\Images\CharacterSprites\Hotaru.png");

	SetLife(180);
	SetTimer(30);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);
	
	SetX(GetCommonData("Boss2X"));
	SetY(GetCommonData("Boss2Y"));
	SetCommonData("Boss2Vanish",1);
	SetMovePosition02(cx,miny+100,50);
	
	SetCommonData("Boss1Move",3);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=4; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

HealthBar();

if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+60,miny+120),1.5);
	}
}


if(GetCommonData("Difficulty")==1){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(4){
		SetShotDirectionType(PLAYER);
		CreateShot01(GetX+10,GetY-45,speed,angle,191,0);
		SetShotDirectionType(ABSOLUTE);
		speed-=0.5;
		}
	angle+=360/12;
	}
usespell=20;
PlaySE(SEshotb6);
}

if(time%150==0 && time>=60 && GetTimer>0){
let angle=atan2(GetPlayerY-GetY-45,GetPlayerX-GetX+10);
	loop(8){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Hotaru - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,angle);
	angle+=360/8;
	}
PlaySE(SEfireworks1);
}

} //Easy

//=============================================================================================================

if(GetCommonData("Difficulty")==2){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(4){
		SetShotDirectionType(PLAYER);
		CreateShot01(GetX+10,GetY-45,speed,angle,191,0);
		SetShotDirectionType(ABSOLUTE);
		speed-=0.5;
		}
	angle+=360/12;
	}
usespell=20;
PlaySE(SEshotb6);
}

if(time%150==0 && time>=60 && GetTimer>0){
let angle=atan2(GetPlayerY-GetY-45,GetPlayerX-GetX+10);
	loop(9){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Hotaru - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,angle);
	angle+=360/9;
	}
PlaySE(SEfireworks1);
}

} //Normal

//=============================================================================================================

if(GetCommonData("Difficulty")==3){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(6){
		SetShotDirectionType(PLAYER);
		CreateShot01(GetX+10,GetY-45,speed,angle,191,0);
		SetShotDirectionType(ABSOLUTE);
		speed-=0.4;
		}
	angle+=360/12;
	}
usespell=20;
PlaySE(SEshotb6);
}

if(time%150==0 && time>=60 && GetTimer>0){
let angle=atan2(GetPlayerY-GetY-45,GetPlayerX-GetX+10);
	loop(9){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Hotaru - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,angle);
	angle+=360/9;
	}
PlaySE(SEfireworks1);
}

} //Hard

//=============================================================================================================

if(GetCommonData("Difficulty")==4){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(8){
		SetShotDirectionType(PLAYER);
		CreateShot01(GetX+10,GetY-45,speed,angle,191,0);
		SetShotDirectionType(ABSOLUTE);
		speed-=0.3;
		}
	angle+=360/12;
	}
usespell=20;
PlaySE(SEshotb6);
}

if(time%150==0 && time>=60 && GetTimer>0){
let angle=atan2(GetPlayerY-GetY-45,GetPlayerX-GetX+10);
	loop(10){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Hotaru - Nonspell 1 - Familiar.txt",GetX,GetY,0,0,angle);
	angle+=360/10;
	}
PlaySE(SEfireworks1);
}

} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss2X",GetX); SetCommonData("Boss2Y",GetY);

#include_function "script/Functions/HealthBar.txt";
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }

	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	if(GetLife>0){ DrawGraphic(GetX,GetY); }
}
 
@Finalize{
}

}